package com.labichaoka.chaoka.ui.baseinfo.person;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.labichaoka.chaoka.R;
import com.labichaoka.chaoka.base.BaseActivity;
import com.labichaoka.chaoka.utils.DetectionUtil;
import com.labichaoka.chaoka.utils.ToastUtils;
import com.labichaoka.chaoka.widget.AutoEmailTextView;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.OnClick;

public class EmailActivity extends BaseActivity {

  @BindView(R.id.right_txt)
  TextView right;
  @BindView(R.id.email)
  AutoEmailTextView email;

  private String emailStr;

  @Override
  protected int initLayoutId() {
    return R.layout.activity_email;
  }

  @Override
  protected void initView() {
    right.setText("完成");
    right.setVisibility(View.VISIBLE);
  }

  @Override
  protected void initData() {

  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    emailStr=getIntent().getExtras().getString("email","");
    if (!TextUtils.isEmpty(emailStr)){
      //ToastUtils.show(emailStr);
      //email.setText(emailStr);
    }

  }

  @OnClick({R.id.right_txt})
  public void click(View v) {
    switch (v.getId()) {
      case R.id.right_txt:
        emailStr=email.getText().toString().trim();

        if(!DetectionUtil.isEmail(emailStr)){
          ToastUtils.show("邮箱格式错误，请重新输入!");
          return;
        }
        EventBus.getDefault().post(emailStr);
        finish();

        break;
    }
  }
}
